﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<CourseSystem.Core.Entities.QuestionLibInfo>" %>

<%@ Import Namespace="Chowpoo.Util" %>
<%@ Import Namespace="CourseSystem.Common.Helpers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    多选题答案管理
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% const string title = "多选题答案管理";
       var fromId = ViewData["fromId"].CheckInt(0);
    %>
    <% Html.RenderPartial("AdminTopUc", title); %>
    <table width="100%" border="0" cellpadding="0" cellspacing="1" class="table03">
        <tr class="box03">
            <td width="50%">
                <%=Model.Title %>
            </td>
            <td height="28">
                <div>
                    <input type="button" id="addChoicesLib" value="添加选项" />
                    <input type="button" id="sumbitForm" value="保存" />
                    <%if (fromId == 0)
                      { %><%=Html.ActionButton("返回", "Lib")%><%}
                      else
                      { %>
                    <%=Html.ActionButton("返回", "ExaminationItem",new{eid=fromId,Model.Type})%>
                    <% } %>
                </div>
            </td>
        </tr>
    </table>
    <table width="100%" height="5" border="0" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
        <tr>
            <td height="5" bgcolor="#FFFFFF">
            </td>
        </tr>
    </table>
    <div id="listDiv">
        <% Html.RenderAction("ChoicesListUc", new { rid = Model.Id }); %>
    </div>
    <div id="editDiv" title="编辑选项">
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeaderContent" runat="server">
    <script type="text/javascript">
        $(function () {
            $("#editDiv").dialog({
                autoOpen: false,
                height: 220,
                width: 550,
                modal: true,
                close: function () {
                    window.location.reload();
                }
            });

            /*$("#addChoicesLib")
            .click(function () {
            $("#editDiv").html("loading...");
            $("#editDiv").load(appRoot + 'AdminExamLib/ChoicesEditUc/?rid=<%=Model.Id %>&rd=' + rdTime());
            $("#editDiv").dialog("open");
            });*/

            $("#addChoicesLib")
                .click(function () {
                    var app = '<tr class="box02" name="content" onmouseover="this.className=\'bg3\'" onmouseout="this.className=\'bg4\'" bgcolor="#FFFFFF"><input id="hidId" name="hidId" type="hidden" value="0" /><td><input id="txtTitle" name="txtTitle" style="width:100%" type="text" value="" /></td><td align="center"><input id="chk" name="chk" type="checkbox"  /></td><td align="center"><a href="javascript:void(0);" onclick="delTr(this);">删除</a></td></tr>';
                    //$(app).appendTo($('tr').last());
                    // alert($('tr[name="content"]').last().html());
                    var addTr = $('tr[name="content"]');
                    if (addTr.length==0) {
                        addTr = $('tr[name="firContent"]');
                    }
                    $(app).insertAfter(addTr.last());
                    // $(app).inse
                });

            $("#sumbitForm").click(function () {
                var chkVal = "";
                $("input[name='chk']").each(function () {
                    chkVal += $(this).attr("checked") + ",";
                });
                $("input[name='chkAll']").val(chkVal);
                $('form').submit();
            }
            );
        });

        var editClickA = function (id) {
            $("#editDiv").html("loading...");
            $("#editDiv").load(appRoot + 'AdminExamLib/ChoicesEditUc/' + id + '?rd=' + rdTime());
            $("#editDiv").dialog("open");
        };
        var delTr = function (thisId) {
            var domObj = $(thisId);
            domObj.parents("tr").remove();
        };
    </script>
</asp:Content>
